package _220321;

import java.util.Scanner;

/**
 * @author ShadowLim
 * @create 2022-03-21-8:41
 */

/**
 * 534ms
 */
public class 带分数 {
    static int ans;
    static int N;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9};
        f(arr, 0);
        System.out.println(ans);
    }

    private static void f(int[] arr, int k) {
        if (k == 9) {
            check(arr);
            return;
        }
        for (int i = k; i < arr.length; i++) {
            int t = arr[i];
            arr[i] = arr[k];
            arr[k] = t;

            f(arr, k + 1);

            t = arr[i];
            arr[i] = arr[k];
            arr[k] = t;
        }
    }

    private static void check(int[] arr) {
        for (int i = 1; i <= 7; i++) {  // +号位置
            int num1 = toInt(arr, 0, i);
            if (num1 >= N) {    // 特判
                continue;
            }
            for (int j = 1; j <= 8 - i; j++) {  // j : num2的长度; 除号前面最多有 9 - i - 1 == 8 - i 最少有 1 个数字
                int num2 = toInt(arr, i, j);
                int num3 = toInt(arr, i + j, 9 - i - j);
                if (num2 % num3 == 0 && num1 + num2 / num3 == N) {
                    ans++;
                }
            }
        }
    }

    private static int toInt(int[] arr, int startPosition, int len) {
        int t = 1, num = 0;
        for (int i = startPosition + len - 1; i >= startPosition ; i--) {
            num += arr[i] * t;
            t *= 10;
        }
        return num;
    }
}
